import {
  type PoolOptions,
  type PoolConnection,
  createPool
} from 'mysql2/promise';

const defaultPoolConfig: PoolOptions = {
  host: 'localhost',
  user: 'root',
  password: '123456',
  database: 'chat_room',
  waitForConnections: true,
  connectionLimit: 10,
  queueLimit: 0
};

let defaultSqlDriver: PoolConnection;

(async function () {
  const pool = createPool(defaultPoolConfig);
  defaultSqlDriver = await pool.getConnection();
})();

export { defaultSqlDriver };
